package com.sanqi.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sanqi.common.annotation.Log;
import com.sanqi.common.core.controller.BaseController;
import com.sanqi.common.core.domain.AjaxResult;
import com.sanqi.common.enums.BusinessType;
import com.sanqi.work.domain.WorkWorkplace;
import com.sanqi.work.service.IWorkWorkplaceService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.sanqi.common.utils.poi.ExcelUtil;
import com.sanqi.common.core.page.TableDataInfo;

/**
 * 职场Controller
 * 
 * @author duany
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/work/workplace")
@Api(tags="职场")
public class WorkWorkplaceController extends BaseController
{
    @Autowired
    private IWorkWorkplaceService workWorkplaceService;

    /**
     * 查询职场列表
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:list')")
    @GetMapping("/list")
    @ApiOperation(value="职场-列表", notes="职场-列表")
    public TableDataInfo list(WorkWorkplace workWorkplace)
    {
        startPage();
        List<WorkWorkplace> list = workWorkplaceService.selectWorkWorkplaceList(workWorkplace);
        return getDataTable(list);
    }

    /**
     * 导出职场列表
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:export')")
    @Log(title = "职场", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value="职场-导出职场列表", notes="职场-导出职场列表")
    public void export(HttpServletResponse response, WorkWorkplace workWorkplace)
    {
        List<WorkWorkplace> list = workWorkplaceService.selectWorkWorkplaceList(workWorkplace);
        ExcelUtil<WorkWorkplace> util = new ExcelUtil<WorkWorkplace>(WorkWorkplace.class);
        util.exportExcel(response, list, "职场数据");
    }

    /**
     * 获取职场详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="职场-获取职场详细信息", notes="职场-获取职场详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workWorkplaceService.selectWorkWorkplaceById(id));
    }

    /**
     * 新增职场
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:add')")
    @Log(title = "职场", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="职场-新增职场", notes="职场-新增职场")
    public AjaxResult add(@RequestBody WorkWorkplace workWorkplace)
    {
        return toAjax(workWorkplaceService.insertWorkWorkplace(workWorkplace));
    }

    /**
     * 修改职场
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:edit')")
    @Log(title = "职场", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="职场-修改职场", notes="职场-修改职场")
    public AjaxResult edit(@RequestBody WorkWorkplace workWorkplace)
    {
        return toAjax(workWorkplaceService.updateWorkWorkplace(workWorkplace));
    }

    /**
     * 删除职场
     */
    @PreAuthorize("@ss.hasPermi('work:workplace:remove')")
    @Log(title = "职场", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="职场-删除职场", notes="职场-删除职场")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workWorkplaceService.deleteWorkWorkplaceByIds(ids));
    }
}
